package com.apes.autoparts.masterdata.model;

import com.alibaba.fastjson.annotation.JSONField;
import com.apes.framework.jpa.ApesBean;
import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.util.DateUtil;
import com.apes.scm.masterdata.enumeration.model.Enumeration;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.util.Date;

/**
 * @ClassName EpcBrand
 * @Description TODO
 * @Author pengyb
 * @Date 2019/11/13 14:55
 * @Version 1.0
 **/
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = EpcBrand.CONST_TABLE_NAME)
public class EpcBrand implements ApesBean {
    public static final String CONST_TABLE_NAME = "mas_ppxx";

    @Id
    @Column(name = "PPID", length = 8)
    @Comment("品牌编码")
    private String id;

    @NotNull
    @Column(name = "PPMC")
    @Comment("品牌名称")
    private String name;

    @Column(name = "YWMC")
    @Comment("英文名称")
    private String enName;

    @Column(name = "PPLXID", length = 8)
    @Comment("品牌类型编码")
    private String brandTypeId;

    @Column(name = "PPLXMC", length = 64)
    @Comment("品牌类型")
    private String brandTypeName;

    @Column(name = "PYM", length = 64)
    @Comment("拼音码")
    private String pinYinMa;

    @Column(name = "PZID", length = 8)
    @Comment("品质编码")
    private String qualityId;

    @Column(name = "PZMC", length = 255)
    @Comment("品质名称")
    private String qualityName;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "quality", referencedColumnName = "id")
    @Comment("品质")
    private Enumeration quality;

    @Column(name = "TS01", nullable = false, length = 36)
    private String time; //时间戳

    @NotNull
    @Column(name = "LRR", length = 64)
    @Comment("录入人")
    private String creatorName;

    @NotNull
    @JSONField(format = DateUtil.SHOW_DATE_FORMAT)
    @Temporal(TemporalType.DATE)
    @Column(name = "LRRQ_SJ")
    @Comment("录入日期")
    private Date entryDate; //录入日期

    @NotNull
    @Column(name = "YXBJ", columnDefinition = "number(2) default 1")
    @Comment("有效标记")
    private boolean valid = true;//有效标记


}
